package com.yanqu.road.server.cmd.player;

import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.PlayerModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

@Cmd(code = Protocol.S_TITLE_UPGRADE, desc = "身份升级")
public class TitleUpgradeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(PlayerModule.class).titleUpgrade();
    }

    @Override
    public void sendData(GamePlayer player) {
        PlayerProto.TitleUpgradeRespMsg.Builder respMsg = PlayerProto.TitleUpgradeRespMsg.newBuilder();
        respMsg.setRet(ret);
        respMsg.setTitleId(player.getTitleId());
        player.sendPacket(Protocol.U_TITLE_UPGRADE, respMsg);
    }

}
